-- @owner: @wan005
-- @date: 2022/3/23
-- @testpoint: ustore表结合系统表pg_database字段执行explain plan
-- @modified: by @daiguatutu 2023/9/5 增加清理序列步骤

--step1:创建ustore表，创建序列，结合序列插入数据   expect:成功
drop table if exists t_s_condition_0004;
create table t_s_condition_0004(col_1 integer,col_2 bigint constraint t_s_condition_0004_pk primary key,col_3 float8,col_4 decimal(12,6),col_5 bool,col_6 char(30),col_7 varchar2(50),col_8 varchar(30),col_9 interval day to second,col_10 timestamp,col_11 date,col_12 smalldatetime,col_13 timestamp without time zone,col_14 blob,col_15 clob,col_16 int[]) with (storage_type=ustore);

drop sequence if exists seq_s_condition_0004;
create sequence seq_s_condition_0004 increment by 1 start with 10;

insert into t_s_condition_0004 values(1,seq_s_condition_0004.nextval,1+445.255,98*0.99,true,lpad('abc','6','@'),lpad('abc','5','b'),rpad('abc','6','e'),(interval '4 5:12:10.222' day to second(3)),to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),  lpad('10','12','01010')::blob,rpad('abc','9','a@123&^%djgk'),'{32,535,5645645,6767,76,67,56,48,979,978,7}');
insert into t_s_condition_0004 values(1,seq_s_condition_0004.nextval,1+445.255,98*0.99,true,lpad('abc','6','@'),lpad('abc','6','b'),rpad('abc','5','e'),(interval '4 5:12:10.222' day to second(3)),to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),  to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),  lpad('10','12','01010')::blob,rpad('abc','9','a@123&^%djgk'),'{32,535,5645645,6767,76,67,56,48,979,978,7}');
insert into t_s_condition_0004 values(2,seq_s_condition_0004.nextval,1+445.255,98*0.99,false,lpad('abc','6','@'),lpad('abc','5','b'),rpad('abc','5','e'),(interval '4 5:12:10.222' day to second(3)),to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),  to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),lpad('10','12','01010')::blob,rpad('abc','9','a@123&^%djgk'),'{43,535,5645645,6767,76,67,56,48,979,978,7}');
insert into t_s_condition_0004 values(3,seq_s_condition_0004.nextval,1+445.255,98*0.99,false,lpad('abc','4','@'),lpad('abc','4','b'),rpad('abc','6','e'),(interval '4 5:12:10.222' day to second(3)),to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),  to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),lpad('10','12','01010')::blob,rpad('abc','9','a@123&^%djgk'),'{32,535,5645645,6767,76,67,56,48,979,978,7}');
insert into t_s_condition_0004 values(3,seq_s_condition_0004.nextval,1+445.255,98*0.99,false,lpad('abc','3','@'),lpad('abc','3','b'),rpad('abc','3','e'),(interval '4 5:07:10.222' day to second(3)),to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'), to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'), lpad('10','12','01010')::blob,rpad('abc','9','a@123&^%djgk'),'{32,535,5645645,6767,76,67,56,48,979,978,7}');
insert into t_s_condition_0004 values(4,seq_s_condition_0004.nextval,1+445.255,98*0.99,true,lpad('abc','3','@'),lpad('abc','4','b'),rpad('abc','6','e'),(interval '4 5:07:10.222' day to second(3)),to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),  to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),to_timestamp('12-sep-10 14:10:10.123000','dd-mon-yy hh24:mi:ss.ff'),lpad('10','12','01010')::blob,rpad('abc','9','a@123&^%djgk'),'{43,535,5645645,6767,76,67,56,48,979,978,7}');

--step2:系统表pg_database结合ustore表left join查看执行计划,存入plan_table中   expect:成功
explain plan for select datconnlimit from pg_database left join t_s_condition_0004 on datconnlimit=col_1;

--step3:查看系统表plan_table中关键字段信息   expect:成功
select operation,options,object_name,object_type,projection from plan_table order by operation,projection;

--step4:环境清理   expect:成功
delete from plan_table;
drop table t_s_condition_0004 cascade;
drop sequence if exists seq_s_condition_0004;
